﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Common.Activities
{
    [Flags]
    public enum UserStepStatus
    {
        Unknown = 0,
        Initialized = 1,
        Started = 2,
        Errored = 4,
        Suspended = 8,
        Completed = 16,
        CompletedWithErrors = 32
    }

    public static class UserStepStatusExtensions
    {
        public static bool IsSet(this UserStepStatus status, UserStepStatus flags)
        {
            // (UserStepStatus.Initialized & UserStepStatus.Initialized) == UserStepStatus.Initialized
            return (status & flags) == flags;
        }

        public static bool IsNotSet(this UserStepStatus status, UserStepStatus flags)
        {
            return (status & (~flags)) == status;
        }

        public static UserStepStatus Set(this UserStepStatus status, UserStepStatus flags)
        {
            return status | flags;
        }

        public static UserStepStatus Clear(this UserStepStatus status, UserStepStatus flags)
        {
            return status & (~flags);
        }
    }
}
